<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>API设置</legend>
            <div>
                <form class="layui-form layui-form-pane" lay-filter="apiset">

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">授权域名</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入授权IP,多个用英文逗号隔开,允许任何人填【*】" name="apiRoster"
                                class="layui-textarea"></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">接口开放</label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="apiSwitch" lay-skin="switch" lay-text="开启|关闭">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">读取缓存</label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="apiDataSwitch" lay-skin="switch" lay-text="开启|关闭">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="apiset">保存</button>
                    </div>
                </form>
            </div>
        </fieldset>
    </div>


</div>

<script>
    layui.use(['form', 'lycms'], function () {
        var form = layui.form
            , layer = layui.layer
            , lycms = layui.lycms;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //监听提交
        form.on('submit(apiset)', function (data) {
            lycms.apisetOperate(data)
            return false;
        });

        // 页面初始化
        $(document).ready(function () {
            //获取初始信息
            $.post("/v1/admin/data/apiset", function (data, status) {
                //表单初始赋值
                form.val('apiset', data);
            });
        });
    });
</script>